﻿// Open Source: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Project: YoProgramo.NET (http://code.google.com/p/yoprogramo/)
// Autor: Fabian Figueredo (info@fabianfigueredo.com.ar)
// Blog: blog.yoprogramo.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Validator;
using YoProgramo.Domain.Core.Interfaces;

namespace YoProgramo.Domain.Core.Entities
{
    public class Story : EntityBase<long>, IStory, IEntityCommon,  IHasAssignedId<long> {

        public override int GetHashCode()
        {
            return (GetType().FullName + "|" +
                    Title + "|" +
                    TextBody).GetHashCode();
        }

        #region IStory Members

        private string _title;
        [Length(5, 250, Message = "El Titulo debe tener entre 5 y 250 caracteres.")]
        [NotNullNotEmpty(Message = "Titulo no puede ser nulo.")]
        public virtual string Title {
            get {
                return _title;
            }
            set {
                _title = value;
            }
        }


        private string _htmlbody;
        [NotNullNotEmpty(Message = "El Cuerpo del mensaje no puede ser nulo.")]
        public string HtmlBody {
            get {
                return _htmlbody;
            }
            set {
                _htmlbody = value;
            }
        }


        private string _textbody;
        [NotNullNotEmpty(Message = "El Cuerpo del mensaje no puede ser nulo.")]
        public string TextBody {
            get {
                return _textbody;
            }
            set {
                _textbody = value;
            }
        }


        private ICategory _category;      
        public virtual ICategory Category {
            get {
                return _category;
            }
            set {
                _category = value;
            }
        }

        private IList<Tag> _tags;
        public IList<Tag> Tags {
            get {
                return _tags;
            }
            set {
                _tags = value;
            }
        }


        private IList<Comment> _comments;
        public IList<Comment> Comments {
            get {
                return _comments;
            }
            set {
                _comments = value;
            }
        }


        private IUser _user;
        public virtual IUser ByUser {
            get {
                return _user;
            }
            set {
                _user = value;
            }
        }


        private string _FromIpAddress;
        public virtual string FromIPAddress {
            get {
                return _FromIpAddress;
            }
            set {
                _FromIpAddress = value;
            }
        }


        private DateTime? _ApprovedAt;
        public virtual DateTime? ApprovedAt {
            get {
                return _ApprovedAt;
            }
            set {
                _ApprovedAt = value;
            }
        }


        private DateTime _PostedAt;
        public virtual DateTime PostedAt {
            get {
                return _PostedAt;
            }
            set {
                _PostedAt = value;
            }
        }


        private DateTime? _LastProcessedAt;
        public virtual DateTime? LastProcessedAt {
            get {
                return _LastProcessedAt;
            }
            set {
                _LastProcessedAt = value;
            }
        }

        #endregion

        #region IHasAssignedId<string> Members

        public virtual void SetAssignedIdTo(long assignedId) {
            //Aqui luego colocar logica para asignacion de id
            Id = assignedId;
        }

        #endregion

        public long Id
        {
            get { return base.Id; }
            set { base.Id = value; }
        }

        private string _slug;
        [NotNullNotEmpty]
        public string Slug {
            get {
                return _slug;
            }
            set {
                _slug = value;
            }
        }

        private bool _islockedout;
        public virtual bool IsLockedOut {
            get { return _islockedout; }
            set { _islockedout = value; }
        }

    }
}